<?php
header('Access-Control-Allow-Origin:*');

$json = file_get_contents("info.json");

$arr = json_decode($json, true); 

$arr_usr = $arr["data"];

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $usr = $_POST['usr'];
  $content = $_POST['content'];
  $time = $_POST['time'];
  $tel = $_POST['tel'];
  $get_data = array("usr" => $usr, "content" => $content, "time" => $time, "tel" => $tel);
  array_push($arr_usr, $get_data);
  $arr["data"] = $arr_usr;
  $json = json_encode($arr, true);
  file_put_contents("info.json", $json);
  echo 200;
} else {
  if (count($arr_usr) <= 0) {
    echo 400;
  } else {
    echo json_encode($arr_usr);
  }
}

